package com.geely.design.pattern.behavioral.responsibilitychain.v1;

public class Doer implements Do {

    private String name;
    Do aDo;

    public Doer(Do aDo,String name) {
        this.aDo = aDo;
        this.name = name;
    }

    public Doer(String name) {
        this.name = name;
    }

    public void setaDo(Do aDo) {
        this.aDo = aDo;
    }

    @Override
    public void doIt() {
        if (aDo != null) {
            aDo.doIt();
        }
        System.out.println(name + "doIt...");
    }
}

class Test{
    public static void main(String[] args) {
        Doer doer1 = new Doer("doer1");
        Doer doer2 = new Doer(doer1, "doer2");
        Doer doer3 = new Doer(doer2, "doer3");

        doer3.doIt();

    }
}
